#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <cstdlib>

void _err_exp();
using namespace std;


int main(int argc, char* argv[])
{
	char c; 
	std::stack<char> op; 
	std::queue<char> exp; //用来存储后缀表达式
    std::stack<double> result; 
	bool point = false;    
	double y=0.0;
	double x=0.0;
	double z=0.0;
	double k=1.0;
		while (true){
			//将中缀表达式转化为后缀表达式
			c=getchar();
			if (c == '\n')
				break;
			if (c == '\t' || c == ' ')
				continue;
			if (c > '0' && c <'9')
				exp.push(c);
			else if (c == '.')
			if (point == false){
				exp.push(c);
				point = true;
			}
			else
				_err_exp();
			else if (c == ')')
			{
			if (op.empty())
				_err_exp();
			while (!op.empty() && op.top() != '(')
			{
				exp.push(op.top());
				op.pop();
			}
			op.pop(); 
			}
		else if (c == '+' || c == '-')
		{
            exp.push('#');
			if (!op.empty())
			{
                
				while (!op.empty() && op.top() != '(')
				{
					exp.push(op.top());
					op.pop();
				}
			}
			op.push(c);
			point = false;
		}
		else if (c == '*' || c == '/')
		{
            exp.push('#');//用于分割两个数据，避免小数与整数的混淆
			if (!op.empty())
			{
                
				while (!op.empty() && 
				       (op.top() == '*' || op.top() == '/'))
				{
					exp.push(op.top());
					op.pop();
				}
			}
			op.push(c);
			point = false;
		}
		else if (c == '(')
			op.push(c);
		else
			_err_exp();//用于判断括号的合法性
	}
	if (!op.empty())
	{
		exp.push('#');
		while (!op.empty())
		{
			exp.push(op.top());
			op.pop();
		}
	}
    while (!exp.empty()){
		while ( exp.front() >= '0' && exp.front() <= '9' ){
            if (exp.empty()) {
                _err_exp();
            }
            else{
			    x = x*10+(exp.front()-'0');
			    exp.pop();
            }
		}
		if ( exp.front() == '.'){
			exp.pop();
            k=0.1;
			while ( exp.front() != '#'&& exp.front() != '+' && exp.front() != '-' && exp.front() != '*'&& exp.front() != '/'){
                if (exp.empty()) {
                    _err_exp();
                }
                else{
                    x += (exp.front()-'0')*k;
			        exp.pop();
			        k = 0.1*k;
                }
			}
			k=1;
		}//将char型的数据转换为double型的数据存储到result栈中
		if(exp.front() == '#'){
            exp.pop();
			result.push(x);
			x=0.0;
        }//将char型的数据转换为double型的数据。当读取到#时将数据存储到result栈中
		//在读取到运算符号时将前面的两个数据弹出进行符号运算。然后将符号运算得到的结果重新压入result栈中。
		if (exp.front() == '+'){
            exp.pop();
			if (!result.empty()) {
                x = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            if (!result.empty()) {
                y = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            result.push(x+y);
            x = 0.0;
            y = 0.0;
        }
        if (exp.front() == '-' ){
			exp.pop();
            if (!result.empty()) {
                x = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            if (!result.empty()) {
                y = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            result.push(y-x);
            x = 0;
            y = 0;
		}
		if (exp.front() == '*' ){
			exp.pop();
            if (!result.empty()) {
                x = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            if (!result.empty()) {
                y = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            result.push(y*x);
            x = 0;
            y = 0;
		}
		if (exp.front() == '/'){
			exp.pop();
            if (!result.empty()) {
                x = result.top();
                result.pop();
            } else {
                _err_exp();
            }
            if (!result.empty()) {
                y = result.top();
                result.pop();
            } else {
                _err_exp();
        	}
            result.push(y/x);
            x = 0;
            y = 0;
        }
	}
    	std::cout << result.top() <<std::endl;
		//最终输出运算的结果
    //while (!exp.empty())
	//{
	//	std::cout << ' ' << exp.front();
	//	exp.pop();
	//}
	//std::cout << std::endl;
	//
    return 0;
};

void _err_exp()
{
	std::cerr << "Illegal expression." << std::endl;
	exit(-1);
};